package com.aya;

import com.aya.mapper.model.ChildBean;
import com.aya.mapper.model.EnvXmlBeanFactory;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class SpringAnalysis {

    @Test
    public void testGetBean() {

        BeanFactory factory = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
        ChildBean bean = factory.getBean(ChildBean.class);
        bean.send();
    }

    @Test
    public void testEnvGetBean() {

        BeanFactory factory = new EnvXmlBeanFactory("applicationContext.xml");
        ChildBean bean = factory.getBean(ChildBean.class);
        bean.send();
    }

    @Test
    public void testApplicationContextGetBean() {
        ApplicationContext factory = new ClassPathXmlApplicationContext("applicationContext.xml");

        ChildBean bean = factory.getBean(ChildBean.class);
        bean.send();
    }
}
